<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a href="http://www.baidu.com">百度</a>
    <script>
        // 阻止 a标签的默认行为
        var aEle = document.querySelector("a");
        aEle.onclick = function(e){
            // 阻止 a标签的默认跳转行为
            e.preventDefault();
            window.location.href = "http://sohu.com";
        }


    </script>
</body>
</html>